package test;

import java.io.File;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class ReadXml {
  public static void main(String[] args) throws Exception {
		SAXReader reader = new SAXReader();
		Document doc = reader.read(new File("src/Entities.xml"));
		Element root = doc.getRootElement();
		List nodeList=root.elements("SingleEntityInfo");
		//System.out.println(nodeList!=null?nodeList.size():-1);
	    Element element = null;  
        //返回的sql  
        String sql = null;  
/*        // 循环此节点,并取出对应的文本信息  
        for (Object obj : nodeList) {  
            element = (Element) obj;  
            sql = element.getTextTrim();  
            System.out.println(sql);
        } */
        
       Element SingleEntityInfo=(Element)nodeList.get(0);
       sql=SingleEntityInfo.element("SqlDefined").element("SqlString").getTextTrim();
       System.out.println(sql);
}
  
}
